﻿using FB.Data.Models;
using FB.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;

namespace FB.Providers.EmployeeInfo
{

    public abstract class CompanyBase : FBAuditModel, IOrder, IRecordState, IEmployeeInfoEntity
    {
        [Key, StringLength(8)]
        [Display(ResourceType = typeof(Resources.Models.Company), Name = "COMCode")]
        public string COMCode { get; set; }

        [Required, StringLength(256)]
        [Display(ResourceType = typeof(Resources.Models.Company), Name = "Name")]
        public string Name { get; set; }

        [NotMapped]
        public string FullName { get { return this.Name; } }

        [StringLength(8)]
        [Display(ResourceType = typeof(Resources.Models.Company), Name = "ParentCOMCode")]
        public string ParentCOMCode { get; set; } 

        [EnumDataType(typeof(RecordState))]
        [Display(ResourceType = typeof(Resources.Models.Company), Name = "RecordState")]
        public RecordState RecordState { get; set; }

        [Display(ResourceType = typeof(Resources.Models.Company), Name = "Order")]
        public int? Order { get; set; }

        public string COMType { get; set; }
    }


    [Table("emp_Companies")]
    public class Company : CompanyBase, IFullName
    {
        [ForeignKey("ParentCOMCode")]
        public virtual Company ParentCompany { get; set; }
        public virtual ICollection<Department> Departments { get; set; }
    }


    [Table("emp_CompanyTypes")]
    public class CompanyType : FBBaseModel
    {
        [Required, StringLength(16)]
        public string Code { get; set; }

        [Required, StringLength(256)]
        public string TypeName { get; set; }
    }
}
